﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AMail.Modules.Messages.Models;
using AMail.Common.Interfaces.Data;

namespace AMail.Modules.Messages.Views
{
  /// <summary>
  /// Interaction logic for MessageView.xaml
  /// </summary>
  public partial class MessageView : UserControl
  {
    public MessageView(IMessageViewModel viewModel)
    {
      InitializeComponent();

      this.DataContext = viewModel;
    }

    private void ContextMenu_Opened(object sender, RoutedEventArgs e)
    {
      
      //attachmentContextMenu
    }
  }

  public class MessageViewerTemplateSelector : DataTemplateSelector
  {
    public DataTemplate TextTemplate { get; set; }
    public DataTemplate HtmlTemplate { get; set; }
    public DataTemplate FileTemplate { get; set; }
    public DataTemplate ImageTemplate { get; set; }

    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
      IMailAttachment attachment = item as IMailAttachment;

      if (attachment == null)
        return null;

      switch (attachment.Type)
      {
        case AttachmentType.Text:
        case AttachmentType.XML:
          return TextTemplate;
        case AttachmentType.HTML:
          return HtmlTemplate;
        case AttachmentType.Image:
          return ImageTemplate;
        default:
          return FileTemplate;
      }

      //return base.SelectTemplate(item, container);
    }
  }
}
